package com.bolt.report.definition;

import com.fasterxml.jackson.annotation.JsonIgnore;

import java.awt.*;
import java.io.Serializable;

public class StyleDefinition implements Serializable, Cloneable {

    private int width;

    private int height;

    private int fontSize;

    private String fontFamily;

    private boolean bold;

    private boolean italic;

    private boolean underline;

    private boolean strik;

    private String bgcolor;

    private String fontColor;

    private BorderDefinition leftBorder;

    private BorderDefinition rightBorder;

    private BorderDefinition topBorder;

    private BorderDefinition bottomBorder;

    private Align align;

    private Align valign;

    private float lineHeight;

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getFontSize() {
        return fontSize;
    }

    public void setFontSize(int fontSize) {
        this.fontSize = fontSize;
    }

    public String getFontFamily() {
        return fontFamily;
    }

    public void setFontFamily(String fontFamily) {
        this.fontFamily = fontFamily;
    }

    public boolean isBold() {
        return bold;
    }

    public void setBold(boolean bold) {
        this.bold = bold;
    }

    public boolean isItalic() {
        return italic;
    }

    public void setItalic(boolean italic) {
        this.italic = italic;
    }

    public boolean isUnderline() {
        return underline;
    }

    public void setUnderline(boolean underline) {
        this.underline = underline;
    }

    public boolean isStrik() {
        return strik;
    }

    public void setStrik(boolean strik) {
        this.strik = strik;
    }

    public String getBgcolor() {
        return bgcolor;
    }

    public void setBgcolor(String bgcolor) {
        this.bgcolor = bgcolor;
    }

    public String getFontColor() {
        return fontColor;
    }

    public void setFontColor(String fontColor) {
        this.fontColor = fontColor;
    }

    public BorderDefinition getLeftBorder() {
        return leftBorder;
    }

    public void setLeftBorder(BorderDefinition leftBorder) {
        this.leftBorder = leftBorder;
    }

    public BorderDefinition getRightBorder() {
        return rightBorder;
    }

    public void setRightBorder(BorderDefinition rightBorder) {
        this.rightBorder = rightBorder;
    }

    public BorderDefinition getTopBorder() {
        return topBorder;
    }

    public void setTopBorder(BorderDefinition topBorder) {
        this.topBorder = topBorder;
    }

    public BorderDefinition getBottomBorder() {
        return bottomBorder;
    }

    public void setBottomBorder(BorderDefinition bottomBorder) {
        this.bottomBorder = bottomBorder;
    }

    public Align getAlign() {
        return align;
    }

    public void setAlign(Align align) {
        this.align = align;
    }

    public Align getValign() {
        return valign;
    }

    public void setValign(Align valign) {
        this.valign = valign;
    }

    @Override
    public StyleDefinition clone() throws CloneNotSupportedException {
        return (StyleDefinition) super.clone();
    }

    public float getLineHeight() {
        return lineHeight;
    }

    public void setLineHeight(float lineHeight) {
        this.lineHeight = lineHeight;
    }

    private Font font;
    @JsonIgnore
    public Font getFont(){
        if(this.font==null){
            int fontStyle=Font.PLAIN;
            if( bold && italic){
                fontStyle=Font.BOLD|Font.ITALIC;
            }else if( bold){
                fontStyle=Font.BOLD;
            }else if( italic){
                fontStyle=Font.ITALIC;
            }
            this.font=new Font(fontFamily,fontStyle,fontSize);
        }
        return this.font;
    }
}